// 统一管理用户相关的接口
import request from '@/utils/http/index';

import { GetUserInfoModel, LoginResultModel } from './model/userModel';

/**
 * api地址
 */
enum Api {
    getRoles = '/system/roles',
    getUsers = '/system/users',
    grantUserRole = '/system/grantUserRole',
    revokeUserRole = '/system/revokeUserRole',
    getUserRoles = '/system/getUserRoles'
}

/**
 * @description: user login api
 */
export const fetchRoles = () => {
  // return request.post<any,LoginResultModel>(Api.Login, params);
  return request.post<LoginResultModel>({ url: Api.getRoles});
}

export const  fetchUsers = () => {
  // return request.post<any,LoginResultModel>(Api.Login, params);
  return request.post<LoginResultModel>({ url: Api.getUsers });
}

/**
 * @description: getUserInfo
 */
export const grantUserRole = (data: any) => {
  // return request.get<any,GetUserInfoModel>(Api.GetUserInfo);
  return request.post<GetUserInfoModel>({url: Api.grantUserRole,data});
}

export const revokeUserRole = (data: any) => {
  // return request.get<any,string[]>(Api.GetPermCode);
  return request.post<GetUserInfoModel>({ url: Api.revokeUserRole,data});
}


export const fetchUserRoles = (data: any) => {
  return request.post({ url: Api.getUserRoles,data});
}

